package com.scsj.supermarket.presenter;

import android.util.Log;

import com.scsj.supermarket.base.TradeAreaBase;
import com.scsj.supermarket.bean.NearByTradeAreaBean;
import com.scsj.supermarket.model.NearbyTradeAreaModel;

import dkmvp.mvp.BasePresenter;
import dkmvp.net.ResponseCallback;
import okhttp3.RequestBody;

/**
 * Created by Administrator on 2018/6/26.
 */

public class NearByTradeAreaPresenter extends BasePresenter implements TradeAreaBase.IPresenter {
    private TradeAreaBase.IView mView;
    private TradeAreaBase.IModel mModel;

    public NearByTradeAreaPresenter(TradeAreaBase.IView mView) {
        this.mView = mView;
        mModel = new NearbyTradeAreaModel();
    }

    @Override
    public void deliverNearTradeData(RequestBody requestBody) {
        addSubscription(mModel.getNearbyTradeArea(requestBody, new ResponseCallback<NearByTradeAreaBean>() {
            @Override
            public void onSuccess(NearByTradeAreaBean result) {

                if (result.getStatusCode() == 200) {

                    mView.showSuccessMsg("获取成功",result);

                } else {
                    mView.showErrorMsg(result.getMsg());
                }
            }

            @Override
            public void onFaild(String msg) {
                mView.showErrorMsg(msg);
                Log.e("onFaild", msg + "");
            }
        }));
    }
}
